import 'package:flutter/material.dart';

class FocusUtil {
  static cancelFocus(BuildContext context) {
    if (hasFocus(context)) {
      FocusManager.instance.primaryFocus!.unfocus();
    }
  }
// 目前是否有
  static bool hasFocus(BuildContext context) {
    FocusScopeNode currentFocus = FocusScope.of(context);
    if (currentFocus.focusedChild != null && !currentFocus.hasPrimaryFocus) {
      return true;
    }
    return false;
  }
}
